from django.shortcuts import render, render_to_response
from django.http import HttpResponse
from django.views.decorators import csrf
# Create your views here.


# def hello(request):
# 	return HttpResponse("Hello, World! ")


def hello(request):
	content = {
		'hello': 'Hello, World! '
	}
	return render(request, 'hello.html', content)


def search_form(request):
	return render_to_response('search_form.html')


def search(request):
	request.encoding = 'utf-8'
	message = '你搜索的内容为: %s' % request.GET['q'] if request.GET.get('q', '') else '你提交了空表单'
	return HttpResponse(message)


def search_post(request):
	ctx = {}
	if request.POST:
		ctx['rlt'] = request.POST['q']
	return render(request, 'post.html', ctx)